//
//  MyViewController.m
//  UI_项目 测试1
//
//  Created by dlios on 15-1-16.
//  Copyright (c) 2015年 songCheng. All rights reserved.
//

#import "MyViewController.h"
#import "TableViewCell1.h"
#import "FocusViewController.h"
#import "PerLetterViewController.h"
#import "CommentViewController.h"
#import "LookViewController.h"
#import "PlayRecordingViewController.h"
#import "SubAlbumViewController.h"
#import "PraiseViewController.h"
#import "ApplyFCViewController.h"
#import "AccountBoundViewController.h"
#import "InstallViewController.h"
#import "ChangeViewController.h"
@interface MyViewController ()

@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"%@",self.tabBarController);
    self.tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen]bounds] style:(UITableViewStylePlain)];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.delegate = self;
    
    self.tableView.dataSource = self;
    
    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 280)];
    
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 50)];
    
    [self.view addSubview:self.tableView];
    
    UIImage *image = [UIImage imageNamed:@"(JACY3I6NNT0OAU%{BZ9J62.jpg"];
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    
    imageView.frame = CGRectMake(0, 0, 375, 200);
    
    [self.tableView addSubview:imageView];
    
    UIImage *image1 = [UIImage imageNamed:@"u=457358582,3720475936&fm=21&gp=0.jpg"];
    
    self.imageView10 = [[UIImageView alloc] initWithImage:image1];
    
    self.imageView10.frame = CGRectMake(150, 60, 80, 80);
    
    self.imageView10.backgroundColor = [UIColor greenColor];
    
    self.imageView10.layer.masksToBounds = YES;
    
    self.imageView10.layer.cornerRadius = 40;
    
    [self.tableView addSubview:self.imageView10];
    
    self.aLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 145, 260, 20)];
    
    // self.aLabel.backgroundColor = [UIColor greenColor];
    
    self.aLabel.text = @"杨永福&&宋城PK桃花侠&&菊花怪";
    
    self.aLabel.textAlignment = NSTextAlignmentCenter;
    
    [self.tableView addSubview:self.aLabel];
    
    self.aLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(80, 175, 240, 15)];
    
    // self.aLabel1.backgroundColor = [UIColor yellowColor];
    
    self.aLabel1.textAlignment = NSTextAlignmentCenter;
    
    self.aLabel1.textColor = [UIColor purpleColor];
    
    self.aLabel1.text = @"这是个懒虫,什么都没有留下......";
    
    self.aLabel1.font = [UIFont fontWithName:@"DIN Condensed" size:14];
    
    [self.tableView addSubview:self.aLabel1];
    
    self.aView = [[UIView alloc] initWithFrame:CGRectMake(0, 210, 375, 45)];
    
    self.aView.backgroundColor = [UIColor blackColor];
    
    [self.tableView addSubview:self.aView];
    
    self.button1 = [UIButton buttonWithType:(UIButtonTypeCustom)];
    
    // self.button1.backgroundColor = [UIColor greenColor];
    
    self.button1.frame = CGRectMake(0, 0, 93, 45);
    
    [self.button1 setTitle:@"关注" forState:(UIControlStateNormal)];
    
    [self.button1 setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    
    [self.button1 setTitleColor:[UIColor blackColor] forState:(UIControlStateHighlighted)];
    
    [self.button1 addTarget:self action:@selector(Action1:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.aView addSubview:self.button1];
    
    self.button2 = [UIButton buttonWithType:(UIButtonTypeCustom)];
    
    // self.button2.backgroundColor = [UIColor greenColor];
    
    self.button2.frame = CGRectMake(94, 0, 94, 45);
    
    [self.button2 setTitle:@"声音" forState:(UIControlStateNormal)];
    
    [self.button2 setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    
    [self.button2 setTitleColor:[UIColor blackColor] forState:(UIControlStateHighlighted)];
    
    [self.button2 addTarget:self action:@selector(Action2:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.aView addSubview:self.button2];
    
    self.button3 = [UIButton buttonWithType:(UIButtonTypeCustom)];
    
    // self.button3.backgroundColor = [UIColor greenColor];
    
    self.button3.frame = CGRectMake(189, 0, 94, 45);
    
    [self.button3 setTitle:@"粉丝" forState:(UIControlStateNormal)];
    
    [self.button3 setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    
    [self.button3 setTitleColor:[UIColor blackColor] forState:(UIControlStateHighlighted)];
    
    [self.button3 addTarget:self action:@selector(Action3:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.aView addSubview:self.button3];
    
    self.button4 = [UIButton buttonWithType:(UIButtonTypeCustom)];
    
    // self.button4.backgroundColor = [UIColor greenColor];
    
    self.button4.frame = CGRectMake(284, 0, 93, 45);
    
    [self.button4 setTitle:@"粉丝" forState:(UIControlStateNormal)];
    
    [self.button4 setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    
    [self.button4 setTitleColor:[UIColor blackColor] forState:(UIControlStateHighlighted)];
    
    [self.button4 addTarget:self action:@selector(Action4:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.aView addSubview:self.button4];
    
    self.button5 = [UIButton buttonWithType:(UIButtonTypeCustom)];
    
    self.button5.frame = CGRectMake(30, 40, 30, 30);
    
    [self.button5 setImage:[UIImage imageNamed:@"iconfont-zuixindongtai.png"] forState:(UIControlStateNormal)];
    [self.button5 addTarget:self action:@selector(Action:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.tableView addSubview:self.button5];
    
    // Do any additional setup after loading the view.
}

- (void)Action:(UIButton *)button
{
    NSLog(@"杨永福PK菊花侠");
    
    ChangeViewController *changeVC = [[ChangeViewController alloc] init];
    
    UINavigationController *changeVCR = [[UINavigationController alloc] initWithRootViewController:changeVC];
    [changeVCR setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
    
    AppDelegate *appDetegate = [[AppDelegate alloc] init];
    
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    
    changeVCR.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:101];
    tabBar.viewControllers = [NSArray arrayWithObjects:changeVCR, nil];
    
    appDetegate.window.rootViewController = tabBar;
    
    [self presentViewController:tabBar animated:YES completion:nil];
    
//    [self presentViewController:tabBar animated:YES completion:nil];
//    [self presentViewController:changeVCR animated:YES completion:^{
//        
//    }];
}

- (void)Action1:(UIButton *)button
{
    FocusViewController *focusVC = [[FocusViewController alloc] init];
    
    UINavigationController *navigationC1 = [[UINavigationController alloc] initWithRootViewController:focusVC];
    [navigationC1 setModalTransitionStyle:(UIModalTransitionStyleCrossDissolve)];
    [self presentViewController:navigationC1 animated:YES completion:^{
        
    }];

}

- (void)Action2:(UIButton *)button
{
    AlbumViewController *album = [[AlbumViewController alloc] init];
    
    UINavigationController *navigationC2 = [[UINavigationController alloc] initWithRootViewController:album];
    [navigationC2 setModalTransitionStyle:(UIModalTransitionStyleCrossDissolve)];
    [self presentViewController:navigationC2 animated:YES completion:^{
        
    }];
    
}
- (void)Action3:(UIButton *)button
{
    VoiceViewController *voiceVC = [[VoiceViewController alloc] init];
    
    UINavigationController *navigationC3 = [[UINavigationController alloc] initWithRootViewController:voiceVC];
    [navigationC3 setModalTransitionStyle:(UIModalTransitionStyleCrossDissolve)];
    [self presentViewController:navigationC3 animated:YES completion:^{
        
    }];
}
- (void)Action4:(UIButton *)button
{
    FansViewController *fansVC = [[FansViewController alloc] init];
    
    UINavigationController *navigationC4 = [[UINavigationController alloc] initWithRootViewController:fansVC];
    [navigationC4 setModalTransitionStyle:(UIModalTransitionStyleCrossDissolve)];
    [self presentViewController:navigationC4 animated:YES completion:^{
        
    }];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 9;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableArray *array00 = [NSMutableArray arrayWithObjects:@"私信", @"寻听友", @"账号绑定", @"我的赞", @"播放记录", @"评论", @"申请认证", @"我在追的呢", @"设置", nil];
    
    static NSString *cell = @"reuse";
    
    TableViewCell1 *viewCell = [tableView dequeueReusableCellWithIdentifier:cell];
    
    if (viewCell == nil) {
        viewCell = [[TableViewCell1 alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:cell];
    }
    
    viewCell.imageView2.image = [UIImage imageNamed:[NSString stringWithFormat:@"picture%ld", indexPath.row]];
    
    viewCell.aLabel1.text = [array00 objectAtIndex:indexPath.row];
    
    return viewCell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 0) {
        
        PerLetterViewController *perLetter = [[PerLetterViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:perLetter];
        
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:100];
        
        
        [self presentViewController:tabBar animated:YES completion:nil];

        
//        [self presentViewController:tabBar animated:YES completion:nil];
        
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
        
    }else if(indexPath.row == 1)
    {
        CommentViewController *commentVC = [[CommentViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:commentVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:101];
        
        [self presentViewController:tabBar animated:YES completion:nil];
        
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];

    }else if(indexPath.row == 2)
    {
        LookViewController *lookVC = [[LookViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:lookVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:102];
        
        [self presentViewController:tabBar animated:YES completion:nil];
        
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
        
    }else if (indexPath.row == 3)
    {
        PlayRecordingViewController *playRec = [[PlayRecordingViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:playRec];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:103];
        
        [self presentViewController:tabBar animated:YES completion:nil];
        
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
    }else if (indexPath.row == 4)
    {
        SubAlbumViewController *subAlbumVC = [[SubAlbumViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:subAlbumVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:104];
        
        [self presentViewController:tabBar animated:YES completion:nil];
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
    }else if (indexPath.row == 5)
    {
        PraiseViewController *praiseVC = [[PraiseViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:praiseVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:105];
        
        [self presentViewController:tabBar animated:YES completion:nil];
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
    }else if (indexPath.row == 6)
    {
        ApplyFCViewController *applyFCVC = [[ApplyFCViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:applyFCVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:106];
        
        [self presentViewController:tabBar animated:YES completion:nil];
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
    }else if (indexPath.row == 7)
    {
        AccountBoundViewController *accountBVC = [[AccountBoundViewController alloc] init];
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:accountBVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCoverVertical)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:107];
        
        [self presentViewController:tabBar animated:YES completion:nil];
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
    }else if (indexPath.row == 8)
    {
        InstallViewController *installVC = [[InstallViewController alloc] init];
        
        UINavigationController *navigationVC = [[UINavigationController alloc] initWithRootViewController:installVC];
        [navigationVC setModalTransitionStyle:(UIModalTransitionStyleCrossDissolve)];
        
        UITabBarController *tabBar = [[UITabBarController alloc] init];
        
        tabBar.viewControllers = [NSArray arrayWithObjects:navigationVC, nil];
        
        tabBar.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:108];
        
        [self presentViewController:tabBar animated:YES completion:nil];
//        [self presentViewController:navigationVC animated:YES completion:^{
//            
//        }];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

 In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
     Get the new view controller using [segue destinationViewController].
     Pass the selected object to the new view controller.
}
*/

@end
